package concept.chapter6.console;

import java.io.Console;

/**
 * Read an integer number from console and print the corresponding ASCII
 * character.
 * 
 * @author kan.sun
 */
public class ConceptProven
{
	public static void main(String[] args)
	{
		Console console = System.console();
		
		while (true)
		{
			assert(console!=null):"Null console!";
			
			String username = console.readLine("%s", "Username: ");

			if(username.equalsIgnoreCase("exit"))
			{
				System.out.println("bye!");
				System.exit(0);
			}
			
			char[] password = console.readPassword("%s", "Password: ");

			System.out.println(String.format("Username: [%s]\nPassword: [%s]", username, new String(password)));
			
		}
	}
}
